<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">




<title>编写属于自己的SQLHelper类，泛型+反射 - .Net热爱者 - 博客园</title>
<meta name="keywords" content="编写属于自己的SQLHelper类,泛型,反射">



<link title="RSS" type="application/rss+xml" rel="alternate" href="http://www.cnblogs.com/floyd/rss">
<link title="RSD" type="application/rsd+xml" rel="EditURI" href="http://www.cnblogs.com/floyd/rsd.xml"> 
  



<link rel="stylesheet" type="text/css" href="index.css" media="all">
</head>
<body>
    <form name="Form1" method="post" action="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html" id="Form1">
<div>
<input name="__EVENTTARGET" id="__EVENTTARGET" value="" type="hidden">
<input name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" type="hidden">
<input name="__VIEWSTATE" id="__VIEWSTATE" value="" type="hidden">
</div>




        
<!--done-->
<div id="home">
<div id="header">
	<div id="blogTitle">
	<a id="lnkBlogLogo" href="http://www.cnblogs.com/floyd/"><img id="blogLogo" src="logo.gif" alt="返回主页"></a>			
		
<!--done-->
<h1><a id="Header1_HeaderTitle" class="headermaintitle" href="http://www.cnblogs.com/floyd/">.Net热爱者</a></h1>
<h2><span>多牛网<a href="http://www.duoniu.xn--cn-3t6ck10bt9idp4a1h2a/" class="smarterwiki-linkify">www.duoniu.cn无赖程序员</a></span></h2>



		
	</div><!--end: blogTitle 博客的标题和副标题 -->
	<div id="navigator">
		
<!--done-->
			<ul id="navList">
				<li><a id="MyLinks1_HomeLink" class="menu" href="http://www.cnblogs.com/">博客园</a></li>
				<li><a id="MyLinks1_SpaceLink" class="menu" href="http://space.cnblogs.com/">社区</a></li>
				<li><a id="MyLinks1_MyHomeLink" class="menu" href="http://www.cnblogs.com/floyd/">首页</a></li>
				<li><a id="MyLinks1_NewPostLink" class="menu" href="http://www.cnblogs.com/floyd/admin/EditPosts.aspx?opt=1">新随笔</a></li>
				<li><a id="MyLinks1_ContactLink" accesskey="9" class="menu" href="http://space.cnblogs.com/msg/send/.Net%e7%83%ad%e7%88%b1%e8%80%85">联系</a></li>
				<li><a id="MyLinks1_Admin" class="menu" href="http://www.cnblogs.com/floyd/admin/EditPosts.aspx">管理</a></li>
				<li><a id="MyLinks1_Syndication" class="menu" href="http://www.cnblogs.com/floyd/rss">订阅</a>
				<a id="MyLinks1_XMLLink" class="aHeaderXML" href="http://www.cnblogs.com/floyd/rss"><img src="rss.gif" alt="订阅" style="border-width: 0px;"></a></li>
			</ul>


		<div class="blogStats">
			
			
<!--done-->
随笔- 6&nbsp;
文章- 0&nbsp;
评论- 35&nbsp;

			
		</div><!--end: blogStats -->
	</div><!--end: navigator 博客导航栏 -->
</div><!--end: header 头部 -->

<div id="main">
	<div id="mainContent">
	<div class="forFlow">
		
					
<!--done-->
<div id="topics">
	<div class="post">
		<h1 class="postTitle">
			<a id="ctl04_TitleUrl" class="postTitle2" href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html">编写属于自己的SQLHelper类，泛型+反射</a>
		</h1>
		<div class="clear"></div>
		<div class="postBody">
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 　　自己一直都是学习使用asp.net mvc框架+linQ的，所以对于ado.net基本上一无所知，最近接了个小项目，所以打算学习+用ado.net来完成。<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 　　首先就想到了，写一个通用点SQLHelper类来辅助完成数据库的操作。<br>
<br>
<span style="font-size: 14pt; color: rgb(0, 0, 255);">1.定义一个类：public class SQLHelper&lt;T&gt; where T : class, new()</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 　　说明：<span style="color: red;">SQLHelper有一个T的泛型类型，T属于class,new()，否则T就不能T t =new T()这样使用new关键字了！</span><br>
<br>
<span style="font-size: 14pt; color: rgb(0, 0, 255);">2.之后就是数据库的链接和关闭等操作：</span><br>
<div class="cnblogs_code"><img style="display: none;" id="Code_Closed_Image_233947" onclick="this.style.display='none'; document.getElementById('Code_Closed_Text_233947').style.display='none'; document.getElementById('Code_Open_Image_233947').style.display='inline'; document.getElementById('Code_Open_Text_233947').style.display='inline';" src="contractedblock.gif" align="top" height="16" width="11"><img id="Code_Open_Image_233947" style="display: inline;" onclick="this.style.display='none'; document.getElementById('Code_Open_Text_233947').style.display='none'; getElementById('Code_Closed_Image_233947').style.display='inline'; getElementById('Code_Closed_Text_233947').style.display='inline';" src="expandedblockstart.gif" align="top" height="16" width="11"><span style="display: none;" id="Code_Closed_Text_233947" class="cnblogs_code_Collapse">Code</span><span id="Code_Open_Text_233947" style="display: inline;"><br>
<!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 128, 128);">&nbsp;1</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;2</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;链接数据库字符串<br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;3</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;/summary&gt;</span><span style="color: rgb(128, 128, 128);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;4</span>&nbsp;<span style="color: rgb(128, 128, 128);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">&nbsp;strConnectionString&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;ConfigurationManager.ConnectionStrings[</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">DataConnectionString</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">].ToString();<br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;5</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;6</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;7</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;数据库连接<br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;8</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;/summary&gt;</span><span style="color: rgb(128, 128, 128);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;9</span>&nbsp;<span style="color: rgb(128, 128, 128);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;SqlConnection&nbsp;Connection&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br>
</span><span style="color: rgb(0, 128, 128);">10</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">11</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;SQLHelper()<br>
</span><span style="color: rgb(0, 128, 128);">12</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">13</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OpenConnect();<br>
</span><span style="color: rgb(0, 128, 128);">14</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">15</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">16</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">17</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;打开数据库连接<br>
</span><span style="color: rgb(0, 128, 128);">18</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;/summary&gt;</span><span style="color: rgb(128, 128, 128);"><br>
</span><span style="color: rgb(0, 128, 128);">19</span>&nbsp;<span style="color: rgb(128, 128, 128);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;OpenConnect()<br>
</span><span style="color: rgb(0, 128, 128);">20</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">21</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">&nbsp;(Connection&nbsp;</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">||</span><span style="color: rgb(0, 0, 0);">&nbsp;Connection.State&nbsp;</span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);">&nbsp;System.Data.ConnectionState.Open)<br>
</span><span style="color: rgb(0, 128, 128);">22</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">23</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Connection&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;SqlConnection(strConnectionString);<br>
</span><span style="color: rgb(0, 128, 128);">24</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">25</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Connection.Open();<br>
</span><span style="color: rgb(0, 128, 128);">26</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">27</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">28</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">29</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">30</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;关闭数据库连接<br>
</span><span style="color: rgb(0, 128, 128);">31</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;/summary&gt;</span><span style="color: rgb(128, 128, 128);"><br>
</span><span style="color: rgb(0, 128, 128);">32</span>&nbsp;<span style="color: rgb(128, 128, 128);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;CloseConnect()<br>
</span><span style="color: rgb(0, 128, 128);">33</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">34</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">&nbsp;(Connection&nbsp;</span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);">&nbsp;Connection.State&nbsp;</span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);">&nbsp;System.Data.ConnectionState.Closed)<br>
</span><span style="color: rgb(0, 128, 128);">35</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">36</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Connection.Close();<br>
</span><span style="color: rgb(0, 128, 128);">37</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">38</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span></div>
<br>
<span style="font-size: 14pt; color: rgb(0, 0, 255);">3.对数据库进行读写操作。</span><br>
<div class="cnblogs_code"><img style="display: none;" id="Code_Closed_Image_234042" onclick="this.style.display='none'; document.getElementById('Code_Closed_Text_234042').style.display='none'; document.getElementById('Code_Open_Image_234042').style.display='inline'; document.getElementById('Code_Open_Text_234042').style.display='inline';" src="contractedblock.gif" align="top" height="16" width="11"><img id="Code_Open_Image_234042" style="display: inline;" onclick="this.style.display='none'; document.getElementById('Code_Open_Text_234042').style.display='none'; getElementById('Code_Closed_Image_234042').style.display='inline'; getElementById('Code_Closed_Text_234042').style.display='inline';" src="expandedblockstart.gif" align="top" height="16" width="11"><span style="display: none;" id="Code_Closed_Text_234042" class="cnblogs_code_Collapse">Code</span><span id="Code_Open_Text_234042" style="display: inline;"><br>
<!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 128, 128);">&nbsp;1</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;2</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;3</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;执行查询语句<br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;4</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;/summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;5</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;param&nbsp;name="strSQL"&gt;</span><span style="color: rgb(0, 128, 0);">SQL语句</span><span style="color: rgb(128, 128, 128);">&lt;/param&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;6</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;param&nbsp;name="obQuery"&gt;</span><span style="color: rgb(0, 128, 0);">SQL参数的值</span><span style="color: rgb(128, 128, 128);">&lt;/param&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;7</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;returns&gt;&lt;/returns&gt;</span><span style="color: rgb(128, 128, 128);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;8</span>&nbsp;<span style="color: rgb(128, 128, 128);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;SqlDataReader&nbsp;ExecReader(</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">&nbsp;strSQL,&nbsp;</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);">&nbsp;obQuery)<br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;9</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">10</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SqlCommand&nbsp;command&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;SqlCommand(strSQL,&nbsp;Connection);<br>
</span><span style="color: rgb(0, 128, 128);">11</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">12</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">&nbsp;(obQuery&nbsp;</span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">)<br>
</span><span style="color: rgb(0, 128, 128);">13</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">14</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PropertyInfo[]&nbsp;pis&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;obQuery.GetType().GetProperties();<br>
</span><span style="color: rgb(0, 128, 128);">15</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">16</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">foreach</span><span style="color: rgb(0, 0, 0);">&nbsp;(var&nbsp;p&nbsp;</span><span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 0);">&nbsp;pis)<br>
</span><span style="color: rgb(0, 128, 128);">17</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">18</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;command.Parameters.Add(</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;SqlParameter(p.Name,&nbsp;p.GetValue(obQuery,&nbsp;</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">)));<br>
</span><span style="color: rgb(0, 128, 128);">19</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">20</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">21</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">22</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SqlDataReader&nbsp;reader&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;command.ExecuteReader();<br>
</span><span style="color: rgb(0, 128, 128);">23</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">24</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">&nbsp;reader;<br>
</span><span style="color: rgb(0, 128, 128);">25</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">26</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">27</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">28</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;执行返回单值的查询语句<br>
</span><span style="color: rgb(0, 128, 128);">29</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;/summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">30</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;param&nbsp;name="strSQL"&gt;</span><span style="color: rgb(0, 128, 0);">SQL语句</span><span style="color: rgb(128, 128, 128);">&lt;/param&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">31</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;param&nbsp;name="obQuery"&gt;</span><span style="color: rgb(0, 128, 0);">SQL参数的值</span><span style="color: rgb(128, 128, 128);">&lt;/param&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">32</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;returns&gt;&lt;/returns&gt;</span><span style="color: rgb(128, 128, 128);"><br>
</span><span style="color: rgb(0, 128, 128);">33</span>&nbsp;<span style="color: rgb(128, 128, 128);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);">&nbsp;ExecSingleValue(</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">&nbsp;strSQL,&nbsp;</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);">&nbsp;obQuery)<br>
</span><span style="color: rgb(0, 128, 128);">34</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">35</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SqlCommand&nbsp;command&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;SqlCommand(strSQL,&nbsp;Connection);<br>
</span><span style="color: rgb(0, 128, 128);">36</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">37</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">38</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">&nbsp;(obQuery&nbsp;</span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">)<br>
</span><span style="color: rgb(0, 128, 128);">39</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">40</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PropertyInfo[]&nbsp;pis&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;obQuery.GetType().GetProperties();<br>
</span><span style="color: rgb(0, 128, 128);">41</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">42</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">foreach</span><span style="color: rgb(0, 0, 0);">&nbsp;(var&nbsp;p&nbsp;</span><span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 0);">&nbsp;pis)<br>
</span><span style="color: rgb(0, 128, 128);">43</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">44</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;command.Parameters.Add(</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;SqlParameter(p.Name,&nbsp;p.GetValue(obQuery,&nbsp;</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">)));<br>
</span><span style="color: rgb(0, 128, 128);">45</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">46</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">47</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">48</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">&nbsp;command.ExecuteScalar();<br>
</span><span style="color: rgb(0, 128, 128);">49</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">50</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">51</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">52</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;执行非查询语句<br>
</span><span style="color: rgb(0, 128, 128);">53</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;/summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">54</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;param&nbsp;name="strSQL"&gt;</span><span style="color: rgb(0, 128, 0);">SQL语句</span><span style="color: rgb(128, 128, 128);">&lt;/param&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">55</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;param&nbsp;name="obQuery"&gt;</span><span style="color: rgb(0, 128, 0);">SQL参数的值</span><span style="color: rgb(128, 128, 128);">&lt;/param&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">56</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;returns&gt;&lt;/returns&gt;</span><span style="color: rgb(128, 128, 128);"><br>
</span><span style="color: rgb(0, 128, 128);">57</span>&nbsp;<span style="color: rgb(128, 128, 128);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;ExecNoQuery(</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">&nbsp;strSQL,&nbsp;</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);">&nbsp;obQuery)<br>
</span><span style="color: rgb(0, 128, 128);">58</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">59</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SqlCommand&nbsp;command&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;SqlCommand(strSQL,&nbsp;Connection);<br>
</span><span style="color: rgb(0, 128, 128);">60</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">61</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">&nbsp;(obQuery&nbsp;</span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">)<br>
</span><span style="color: rgb(0, 128, 128);">62</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">63</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PropertyInfo[]&nbsp;pis&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;obQuery.GetType().GetProperties();<br>
</span><span style="color: rgb(0, 128, 128);">64</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">65</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">foreach</span><span style="color: rgb(0, 0, 0);">&nbsp;(var&nbsp;p&nbsp;</span><span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 0);">&nbsp;pis)<br>
</span><span style="color: rgb(0, 128, 128);">66</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">67</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;command.Parameters.Add(</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;SqlParameter(p.Name,&nbsp;p.GetValue(obQuery,&nbsp;</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">)));<br>
</span><span style="color: rgb(0, 128, 128);">68</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">69</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">70</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">71</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">&nbsp;command.ExecuteNonQuery();<br>
</span><span style="color: rgb(0, 128, 128);">72</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span></div>
解释:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 　　//判断是SQL语句中参数的值对象是否为空<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 　　//例如：new{Id=1,Name="Test"}<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (obQuery != null)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 　　&nbsp;&nbsp;&nbsp; //获取SQL语句中参数的值对象中的属性类型和值<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PropertyInfo[] pis = obQuery.GetType().GetProperties();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 　　&nbsp;&nbsp;&nbsp; //循环遍历对象中的属性<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (var p in pis)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 　　&nbsp;&nbsp;&nbsp;&nbsp;  　//利用反射将Id,Name等值填充到SQL语句中的参数中<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; command.Parameters.Add(new SqlParameter(p.Name, p.GetValue(obQuery, null)));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
<br>
查询操作中，返回的是SQLDataReader对象，如何获取我们所需要的列表，分页，单个实体呢？<br>
<span style="font-size: 14pt; color: rgb(0, 0, 255);">4.返回列表List&lt;T&gt;，还是利用泛型+反射</span><br>
<div class="cnblogs_code"><img style="display: none;" id="Code_Closed_Image_234526" onclick="this.style.display='none'; document.getElementById('Code_Closed_Text_234526').style.display='none'; document.getElementById('Code_Open_Image_234526').style.display='inline'; document.getElementById('Code_Open_Text_234526').style.display='inline';" src="contractedblock.gif" align="top" height="16" width="11"><img id="Code_Open_Image_234526" style="display: inline;" onclick="this.style.display='none'; document.getElementById('Code_Open_Text_234526').style.display='none'; getElementById('Code_Closed_Image_234526').style.display='inline'; getElementById('Code_Closed_Text_234526').style.display='inline';" src="expandedblockstart.gif" align="top" height="16" width="11"><span style="display: none;" id="Code_Closed_Text_234526" class="cnblogs_code_Collapse">Code</span><span id="Code_Open_Text_234526" style="display: inline;"><br>
<!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 128, 128);">&nbsp;1</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;2</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;获取列表<br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;3</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;/summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;4</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;param&nbsp;name="strSQL"&gt;</span><span style="color: rgb(0, 128, 0);">SQL语句</span><span style="color: rgb(128, 128, 128);">&lt;/param&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;5</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;param&nbsp;name="obQuery"&gt;</span><span style="color: rgb(0, 128, 0);">SQL参数的值</span><span style="color: rgb(128, 128, 128);">&lt;/param&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;6</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;returns&gt;&lt;/returns&gt;</span><span style="color: rgb(128, 128, 128);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;7</span>&nbsp;<span style="color: rgb(128, 128, 128);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;List</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">T</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;GetList(</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">&nbsp;strSQL,&nbsp;</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);">&nbsp;obQuery)<br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;8</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;9</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">调用执行查询语句函数，返回SqlDataReader</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">10</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SqlDataReader&nbsp;reader&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;ExecReader(strSQL,&nbsp;obQuery);<br>
</span><span style="color: rgb(0, 128, 128);">11</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">定义返回的列表</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">12</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;List</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">T</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;list&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;List</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">T</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">();<br>
</span><span style="color: rgb(0, 128, 128);">13</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">定义T类型的实体</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">14</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T&nbsp;model&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;T();<br>
</span><span style="color: rgb(0, 128, 128);">15</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">获取T类型实体的属性类型和值</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">16</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PropertyInfo[]&nbsp;pis&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;model.GetType().GetProperties();<br>
</span><span style="color: rgb(0, 128, 128);">17</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">获取数据库返回的列数</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">18</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;intColCount&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;reader.FieldCount;<br>
</span><span style="color: rgb(0, 128, 128);">19</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">遍历SqlDataReader</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">20</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);">&nbsp;(reader.Read())<br>
</span><span style="color: rgb(0, 128, 128);">21</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">22</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">定义</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">23</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;value_number&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 128);">0</span><span style="color: rgb(0, 0, 0);">;<br>
</span><span style="color: rgb(0, 128, 128);">24</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">重新实例化T</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">25</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;model&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;T();<br>
</span><span style="color: rgb(0, 128, 128);">26</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">从数据库拿出一条数据后，循环遍历T类型的属性类型和值</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">27</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">&nbsp;(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;i&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 128);">0</span><span style="color: rgb(0, 0, 0);">;&nbsp;i&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">&nbsp;intColCount;&nbsp;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)<br>
</span><span style="color: rgb(0, 128, 128);">28</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">29</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">判断第一列是否为row_number，此为分页使用</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">30</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">&nbsp;(reader.GetName(i)&nbsp;</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">row_number</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">)&nbsp;value_number</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">;<br>
</span><span style="color: rgb(0, 128, 128);">31</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">设置T对应属性的值</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">32</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pis[i].SetValue(model,&nbsp;reader.GetValue(value_number),&nbsp;</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">);<br>
</span><span style="color: rgb(0, 128, 128);">33</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value_number</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">;<br>
</span><span style="color: rgb(0, 128, 128);">34</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">35</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">将T添加到列表中</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">36</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;list.Add(model);<br>
</span><span style="color: rgb(0, 128, 128);">37</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">38</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">39</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">&nbsp;list;<br>
</span><span style="color: rgb(0, 128, 128);">40</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span></div>
<br>
<span style="font-size: 14pt; color: rgb(0, 0, 255);">5.返回分页，获取PagesList&lt;T&gt;</span><br>
5.1。分页实体类：<br>
<div class="cnblogs_code"><img style="display: none;" id="Code_Closed_Image_234623" onclick="this.style.display='none'; document.getElementById('Code_Closed_Text_234623').style.display='none'; document.getElementById('Code_Open_Image_234623').style.display='inline'; document.getElementById('Code_Open_Text_234623').style.display='inline';" src="contractedblock.gif" align="top" height="16" width="11"><img id="Code_Open_Image_234623" style="display: inline;" onclick="this.style.display='none'; document.getElementById('Code_Open_Text_234623').style.display='none'; getElementById('Code_Closed_Image_234623').style.display='inline'; getElementById('Code_Closed_Text_234623').style.display='inline';" src="expandedblockstart.gif" align="top" height="16" width="11"><span style="display: none;" id="Code_Closed_Text_234623" class="cnblogs_code_Collapse">Code</span><span id="Code_Open_Text_234623" style="display: inline;"><br>
<!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 128, 128);">&nbsp;1</span>&nbsp;<span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">&nbsp;PagedList</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">T</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;:&nbsp;List</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">T</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;2</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;3</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;4</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;分页编号<br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;5</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;/summary&gt;</span><span style="color: rgb(128, 128, 128);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;6</span>&nbsp;<span style="color: rgb(128, 128, 128);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;intPageIndex&nbsp;{&nbsp;</span><span style="color: rgb(0, 0, 255);">get</span><span style="color: rgb(0, 0, 0);">;&nbsp;</span><span style="color: rgb(0, 0, 255);">set</span><span style="color: rgb(0, 0, 0);">;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;7</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;8</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;9</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;分页大小<br>
</span><span style="color: rgb(0, 128, 128);">10</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;/summary&gt;</span><span style="color: rgb(128, 128, 128);"><br>
</span><span style="color: rgb(0, 128, 128);">11</span>&nbsp;<span style="color: rgb(128, 128, 128);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;intPageSize&nbsp;{&nbsp;</span><span style="color: rgb(0, 0, 255);">get</span><span style="color: rgb(0, 0, 0);">;&nbsp;</span><span style="color: rgb(0, 0, 255);">set</span><span style="color: rgb(0, 0, 0);">;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">12</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">13</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">14</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;分页数<br>
</span><span style="color: rgb(0, 128, 128);">15</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;/summary&gt;</span><span style="color: rgb(128, 128, 128);"><br>
</span><span style="color: rgb(0, 128, 128);">16</span>&nbsp;<span style="color: rgb(128, 128, 128);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;intPages&nbsp;{&nbsp;</span><span style="color: rgb(0, 0, 255);">get</span><span style="color: rgb(0, 0, 0);">;&nbsp;</span><span style="color: rgb(0, 0, 255);">set</span><span style="color: rgb(0, 0, 0);">;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">17</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">18</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">19</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;总元素的个数<br>
</span><span style="color: rgb(0, 128, 128);">20</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;/summary&gt;</span><span style="color: rgb(128, 128, 128);"><br>
</span><span style="color: rgb(0, 128, 128);">21</span>&nbsp;<span style="color: rgb(128, 128, 128);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;intTotalCount&nbsp;{&nbsp;</span><span style="color: rgb(0, 0, 255);">get</span><span style="color: rgb(0, 0, 0);">;&nbsp;</span><span style="color: rgb(0, 0, 255);">set</span><span style="color: rgb(0, 0, 0);">;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">22</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">23</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">24</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;此分页元素的个数<br>
</span><span style="color: rgb(0, 128, 128);">25</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;/summary&gt;</span><span style="color: rgb(128, 128, 128);"><br>
</span><span style="color: rgb(0, 128, 128);">26</span>&nbsp;<span style="color: rgb(128, 128, 128);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;intCount&nbsp;{&nbsp;</span><span style="color: rgb(0, 0, 255);">get</span><span style="color: rgb(0, 0, 0);">;&nbsp;</span><span style="color: rgb(0, 0, 255);">set</span><span style="color: rgb(0, 0, 0);">;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">27</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">28</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">29</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;是否有下一页<br>
</span><span style="color: rgb(0, 128, 128);">30</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;/summary&gt;</span><span style="color: rgb(128, 128, 128);"><br>
</span><span style="color: rgb(0, 128, 128);">31</span>&nbsp;<span style="color: rgb(128, 128, 128);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">bool</span><span style="color: rgb(0, 0, 0);">&nbsp;HasNextPage&nbsp;{&nbsp;</span><span style="color: rgb(0, 0, 255);">get</span><span style="color: rgb(0, 0, 0);">;&nbsp;</span><span style="color: rgb(0, 0, 255);">set</span><span style="color: rgb(0, 0, 0);">;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">32</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">33</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">34</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;是否有上一页<br>
</span><span style="color: rgb(0, 128, 128);">35</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;/summary&gt;</span><span style="color: rgb(128, 128, 128);"><br>
</span><span style="color: rgb(0, 128, 128);">36</span>&nbsp;<span style="color: rgb(128, 128, 128);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">bool</span><span style="color: rgb(0, 0, 0);">&nbsp;HasPrPage&nbsp;{&nbsp;</span><span style="color: rgb(0, 0, 255);">get</span><span style="color: rgb(0, 0, 0);">;&nbsp;</span><span style="color: rgb(0, 0, 255);">set</span><span style="color: rgb(0, 0, 0);">;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">37</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">38</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;PagedList(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;intPageIndex,&nbsp;</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;intPageSize)<br>
</span><span style="color: rgb(0, 128, 128);">39</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">40</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.intPageIndex&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;intPageIndex;<br>
</span><span style="color: rgb(0, 128, 128);">41</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.intPageSize&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;intPageSize;<br>
</span><span style="color: rgb(0, 128, 128);">42</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">43</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;}</span></span></div>
<br>
5.2。实现分页，返回PagesList&lt;T&gt;<br>
<div class="cnblogs_code"><img style="display: none;" id="Code_Closed_Image_234704" onclick="this.style.display='none'; document.getElementById('Code_Closed_Text_234704').style.display='none'; document.getElementById('Code_Open_Image_234704').style.display='inline'; document.getElementById('Code_Open_Text_234704').style.display='inline';" src="contractedblock.gif" align="top" height="16" width="11"><img id="Code_Open_Image_234704" style="display: inline;" onclick="this.style.display='none'; document.getElementById('Code_Open_Text_234704').style.display='none'; getElementById('Code_Closed_Image_234704').style.display='inline'; getElementById('Code_Closed_Text_234704').style.display='inline';" src="expandedblockstart.gif" align="top" height="16" width="11"><span style="display: none;" id="Code_Closed_Text_234704" class="cnblogs_code_Collapse">Code</span><span id="Code_Open_Text_234704" style="display: inline;"><br>
<!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 128, 128);">&nbsp;1</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;2</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;获取分页<br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;3</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;/summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;4</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;param&nbsp;name="strTotalSQL"&gt;</span><span style="color: rgb(0, 128, 0);">总共个数的SQL</span><span style="color: rgb(128, 128, 128);">&lt;/param&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;5</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;param&nbsp;name="obTotalQuery"&gt;</span><span style="color: rgb(0, 128, 0);">总共个数的SQL参数的值</span><span style="color: rgb(128, 128, 128);">&lt;/param&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;6</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;param&nbsp;name="strSQL"&gt;</span><span style="color: rgb(0, 128, 0);">分页的SQL</span><span style="color: rgb(128, 128, 128);">&lt;/param&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;7</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;param&nbsp;name="obQuery"&gt;</span><span style="color: rgb(0, 128, 0);">分页SQL参数的值</span><span style="color: rgb(128, 128, 128);">&lt;/param&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;8</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;param&nbsp;name="intPageIndex"&gt;</span><span style="color: rgb(0, 128, 0);">分页编号</span><span style="color: rgb(128, 128, 128);">&lt;/param&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;9</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;param&nbsp;name="intPageSize"&gt;</span><span style="color: rgb(0, 128, 0);">分页大小</span><span style="color: rgb(128, 128, 128);">&lt;/param&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">10</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;returns&gt;&lt;/returns&gt;</span><span style="color: rgb(128, 128, 128);"><br>
</span><span style="color: rgb(0, 128, 128);">11</span>&nbsp;<span style="color: rgb(128, 128, 128);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;PagedList</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">T</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;GetPageList(</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">&nbsp;strTotalSQL,&nbsp;</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);">&nbsp;obTotalQuery,&nbsp;</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">&nbsp;strSQL,&nbsp;</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);">&nbsp;obQuery,&nbsp;</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;intPageIndex,&nbsp;</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;intPageSize)<br>
</span><span style="color: rgb(0, 128, 128);">12</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">13</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">定义分页对象的编号和大小</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">14</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PagedList</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">T</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;pageList&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;PagedList</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">T</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">(intPageIndex,&nbsp;intPageSize);<br>
</span><span style="color: rgb(0, 128, 128);">15</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">执行获取单个值的函数，设置分页对象的总元素</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">16</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pageList.intTotalCount&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">)ExecSingleValue(strTotalSQL,&nbsp;obTotalQuery);<br>
</span><span style="color: rgb(0, 128, 128);">17</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">设置分页对象的分页数</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">18</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">&nbsp;(pageList.intTotalCount&nbsp;</span><span style="color: rgb(0, 0, 0);">%</span><span style="color: rgb(0, 0, 0);">&nbsp;intPageSize&nbsp;</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 128);">0</span><span style="color: rgb(0, 0, 0);">)&nbsp;pageList.intPages&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;pageList.intTotalCount&nbsp;</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">&nbsp;intPageSize;<br>
</span><span style="color: rgb(0, 128, 128);">19</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);">&nbsp;pageList.intPages&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;pageList.intTotalCount&nbsp;</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">&nbsp;intPageSize&nbsp;</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 128);">1</span><span style="color: rgb(0, 0, 0);">;<br>
</span><span style="color: rgb(0, 128, 128);">20</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">定义列表，调用获取列表的函数获取此分页的元素</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">21</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;List</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">T</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;list&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;GetList(strSQL,&nbsp;obQuery);<br>
</span><span style="color: rgb(0, 128, 128);">22</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">将列表元素添加到分页对象当中</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">23</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pageList.AddRange(list);<br>
</span><span style="color: rgb(0, 128, 128);">24</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">设置分页对象是否有上一页和下一页</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">25</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pageList.HasNextPage&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;pageList.intPageIndex&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">&nbsp;pageList.intPages&nbsp;</span><span style="color: rgb(0, 0, 0);">?</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">&nbsp;:&nbsp;</span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">;<br>
</span><span style="color: rgb(0, 128, 128);">26</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pageList.HasPrPage&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;pageList.intPageIndex&nbsp;</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 128);">1</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">?</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">&nbsp;:&nbsp;</span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">;<br>
</span><span style="color: rgb(0, 128, 128);">27</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">28</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">&nbsp;pageList;<br>
</span><span style="color: rgb(0, 128, 128);">29</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span></div>
<br>
<span style="font-size: 14pt; color: rgb(0, 0, 255);">6.获取单个实体类：T</span><br>
<div class="cnblogs_code"><img style="display: none;" id="Code_Closed_Image_234744" onclick="this.style.display='none'; document.getElementById('Code_Closed_Text_234744').style.display='none'; document.getElementById('Code_Open_Image_234744').style.display='inline'; document.getElementById('Code_Open_Text_234744').style.display='inline';" src="contractedblock.gif" align="top" height="16" width="11"><img id="Code_Open_Image_234744" style="display: inline;" onclick="this.style.display='none'; document.getElementById('Code_Open_Text_234744').style.display='none'; getElementById('Code_Closed_Image_234744').style.display='inline'; getElementById('Code_Closed_Text_234744').style.display='inline';" src="expandedblockstart.gif" align="top" height="16" width="11"><span style="display: none;" id="Code_Closed_Text_234744" class="cnblogs_code_Collapse">Code</span><span id="Code_Open_Text_234744" style="display: inline;"><br>
<!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 128, 128);">&nbsp;1</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;2</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;获取单个实体<br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;3</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;/summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;4</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;param&nbsp;name="strSQL"&gt;</span><span style="color: rgb(0, 128, 0);">SQL语句</span><span style="color: rgb(128, 128, 128);">&lt;/param&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;5</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;param&nbsp;name="obQuery"&gt;</span><span style="color: rgb(0, 128, 0);">SQL参数的值</span><span style="color: rgb(128, 128, 128);">&lt;/param&gt;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;6</span>&nbsp;<span style="color: rgb(0, 128, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;returns&gt;&lt;/returns&gt;</span><span style="color: rgb(128, 128, 128);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;7</span>&nbsp;<span style="color: rgb(128, 128, 128);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;T&nbsp;GetTM(</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">&nbsp;strSQL,&nbsp;</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);">&nbsp;obQuery)<br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;8</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;9</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">调用执行查询语句，返回SqlDataReader</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">10</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SqlDataReader&nbsp;reader&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;ExecReader(strSQL,&nbsp;obQuery);<br>
</span><span style="color: rgb(0, 128, 128);">11</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">新建一个T类型</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">12</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T&nbsp;model&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;T();<br>
</span><span style="color: rgb(0, 128, 128);">13</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">获取T类型的属性类型和值</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">14</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PropertyInfo[]&nbsp;pis&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;model.GetType().GetProperties();<br>
</span><span style="color: rgb(0, 128, 128);">15</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">获取数据库返回数据的列数</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">16</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;intColCount&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;reader.FieldCount;<br>
</span><span style="color: rgb(0, 128, 128);">17</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">读取数据，填充T</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">18</span>&nbsp;<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">&nbsp;(reader.Read())<br>
</span><span style="color: rgb(0, 128, 128);">19</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">20</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;value_number&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 128);">0</span><span style="color: rgb(0, 0, 0);">;<br>
</span><span style="color: rgb(0, 128, 128);">21</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">&nbsp;(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;i&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 128);">0</span><span style="color: rgb(0, 0, 0);">;&nbsp;i&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">&nbsp;intColCount;&nbsp;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)<br>
</span><span style="color: rgb(0, 128, 128);">22</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">23</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pis[i].SetValue(model,&nbsp;reader.GetValue(value_number),&nbsp;</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">);<br>
</span><span style="color: rgb(0, 128, 128);">24</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value_number</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">;<br>
</span><span style="color: rgb(0, 128, 128);">25</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">26</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">27</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">28</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">&nbsp;model;<br>
</span><span style="color: rgb(0, 128, 128);">29</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span></div>
<br>
<span style="font-size: 14pt; color: rgb(0, 0, 255);">7.调用方法：ResumeTM为数据库表的实体类</span>
<div class="cnblogs_code"><img style="display: none;" id="Code_Closed_Image_234836" onclick="this.style.display='none'; document.getElementById('Code_Closed_Text_234836').style.display='none'; document.getElementById('Code_Open_Image_234836').style.display='inline'; document.getElementById('Code_Open_Text_234836').style.display='inline';" src="contractedblock.gif" align="top" height="16" width="11"><img id="Code_Open_Image_234836" style="display: inline;" onclick="this.style.display='none'; document.getElementById('Code_Open_Text_234836').style.display='none'; getElementById('Code_Closed_Image_234836').style.display='inline'; getElementById('Code_Closed_Text_234836').style.display='inline';" src="expandedblockstart.gif" align="top" height="16" width="11"><span style="display: none;" id="Code_Closed_Text_234836" class="cnblogs_code_Collapse">Code</span><span id="Code_Open_Text_234836" style="display: inline;"><br>
<!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 128, 128);">&nbsp;1</span>&nbsp;<span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;List</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">ResumeTM</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;GetResumeByJobInfoId(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;intJobInfoId)<br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;2</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;3</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SQLHelper</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">ResumeTM</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;helper&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;SQLHelper</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">ResumeTM</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">();<br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;4</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;5</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">&nbsp;strSQL&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 0);">@"</span><span style="color: rgb(128, 0, 0);">select&nbsp;*&nbsp;from&nbsp;Resume&nbsp;where&nbsp;FirstJobId=@JobInfoId&nbsp;or&nbsp;SecondJobId=@JobInfoId&nbsp;order&nbsp;by&nbsp;CreateTime&nbsp;desc</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;6</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;7</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);">&nbsp;obQuery&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;{&nbsp;JobInfoId</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">intJobInfoId};<br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;8</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;9</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;List</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">ResumeTM</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;list&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;helper.GetList(strSQL,&nbsp;obQuery);<br>
</span><span style="color: rgb(0, 128, 128);">10</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">11</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;helper.CloseConnect();<br>
</span><span style="color: rgb(0, 128, 128);">12</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">13</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">&nbsp;list;<br>
</span><span style="color: rgb(0, 128, 128);">14</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">15</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">16</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;ResumeTM&nbsp;GetResumeById(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;intId)<br>
</span><span style="color: rgb(0, 128, 128);">17</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">18</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SQLHelper</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">ResumeTM</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;helper&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;SQLHelper</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">ResumeTM</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">();<br>
</span><span style="color: rgb(0, 128, 128);">19</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">20</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">&nbsp;strSQL&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 0);">@"</span><span style="color: rgb(128, 0, 0);">select&nbsp;*&nbsp;from&nbsp;Resume&nbsp;where&nbsp;Id=@Id</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br>
</span><span style="color: rgb(0, 128, 128);">21</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">22</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);">&nbsp;obQuery&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;{&nbsp;Id</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">intId};<br>
</span><span style="color: rgb(0, 128, 128);">23</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">24</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ResumeTM&nbsp;tm&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;helper.GetTM(strSQL,&nbsp;obQuery);<br>
</span><span style="color: rgb(0, 128, 128);">25</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">26</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;helper.CloseConnect();<br>
</span><span style="color: rgb(0, 128, 128);">27</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">28</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">&nbsp;tm;<br>
</span><span style="color: rgb(0, 128, 128);">29</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">30</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">31</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;PagedList</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">ResumeTM</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;GetResume(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;intPageIndex,&nbsp;</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;intPaegSize)<br>
</span><span style="color: rgb(0, 128, 128);">32</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">33</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SQLHelper</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">ResumeTM</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;helper&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;SQLHelper</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">ResumeTM</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">();<br>
</span><span style="color: rgb(0, 128, 128);">34</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">35</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">&nbsp;strTotalCount&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 0);">@"</span><span style="color: rgb(128, 0, 0);">select&nbsp;count(*)&nbsp;from&nbsp;Resume</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br>
</span><span style="color: rgb(0, 128, 128);">36</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">37</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">&nbsp;strSQL&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 0);">@"</span><span style="color: rgb(128, 0, 0);">select&nbsp;*&nbsp;from<br>
</span><span style="color: rgb(0, 128, 128);">38</span>&nbsp;<span style="color: rgb(128, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(<br>
</span><span style="color: rgb(0, 128, 128);">39</span>&nbsp;<span style="color: rgb(128, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select&nbsp;row_number()&nbsp;over(order&nbsp;by&nbsp;CreateTime&nbsp;desc)&nbsp;as&nbsp;row_number,*&nbsp;from&nbsp;Resume<br>
</span><span style="color: rgb(0, 128, 128);">40</span>&nbsp;<span style="color: rgb(128, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;as&nbsp;t0<br>
</span><span style="color: rgb(0, 128, 128);">41</span>&nbsp;<span style="color: rgb(128, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;where&nbsp;t0.row_number&nbsp;between&nbsp;@intPageSize*(@intPageIndex-1)+1&nbsp;and&nbsp;@ingPageSize*@intPageIndex</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br>
</span><span style="color: rgb(0, 128, 128);">42</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);">&nbsp;obQuery&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;{&nbsp;intPageSize</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">intPaegSize,intPageIndex</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">intPageIndex};<br>
</span><span style="color: rgb(0, 128, 128);">43</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">44</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PagedList</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">ResumeTM</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;list&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;helper.GetPageList(strTotalCount,&nbsp;</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">,&nbsp;strSQL,&nbsp;obQuery,&nbsp;intPageIndex,&nbsp;intPaegSize);<br>
</span><span style="color: rgb(0, 128, 128);">45</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">46</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;helper.CloseConnect();<br>
</span><span style="color: rgb(0, 128, 128);">47</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">48</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">&nbsp;list;<br>
</span><span style="color: rgb(0, 128, 128);">49</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: rgb(0, 128, 128);">50</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">51</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;Delete(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;intId)<br>
</span><span style="color: rgb(0, 128, 128);">52</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: rgb(0, 128, 128);">53</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SQLHelper</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">ResumeTM</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;helper&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;SQLHelper</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">ResumeTM</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">();<br>
</span><span style="color: rgb(0, 128, 128);">54</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">55</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">&nbsp;strSQL&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 0);">@"</span><span style="color: rgb(128, 0, 0);">delete&nbsp;from&nbsp;Resume&nbsp;where&nbsp;Id=@Id</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br>
</span><span style="color: rgb(0, 128, 128);">56</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">57</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);">&nbsp;obQuery&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;{&nbsp;Id</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">intId};<br>
</span><span style="color: rgb(0, 128, 128);">58</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">59</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;helper.ExecNoQuery(strSQL,&nbsp;obQuery);<br>
</span><span style="color: rgb(0, 128, 128);">60</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">61</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;helper.CloseConnect();<br>
</span><span style="color: rgb(0, 128, 128);">62</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span></div>
<br>
哈哈。。写好了。。。有什么写得不好的，希望大家多多指教。拍拍砖。。。<br>
<br>

<div id="digg_block">
<div id="div_digg">										
	<div class="diggit" onclick="DiggIt(1559936,53922,1)"> 
		<span class="diggnum" id="digg_count_1559936">2</span>
	</div>
	<div class="buryit" onclick="DiggIt(1559936,53922,2)"> 
		<span class="burynum" id="bury_count_1559936">0</span>
	</div>
	<div class="clear"></div>
	<span style="display: none;" id="span_isdigged_1559936">0</span>	
	<div class="diggword" id="digg_word_1559936">(请您对文章做出评价)</div>	
</div>
</div>
<div class="clear"></div>
<div id="post_next_prev">
<a href="http://www.cnblogs.com/floyd/archive/2009/06/17/1505117.html">« </a> 上一篇：<a href="http://www.cnblogs.com/floyd/archive/2009/06/17/1505117.html" title="发布于2009-06-17 15:11">Unity+单例模式的依赖注入</a><br>

</div>








		</div>
		<div class="postDesc">posted @ 2009-09-04 00:05 <a href="http://www.cnblogs.com/floyd/">.Net热爱者</a> 阅读(3265) <a href="#commentform">评论(27)</a> &nbsp;<a href="http://www.cnblogs.com/floyd/admin/EditPosts.aspx?postid=1559936">编辑</a> <a href="http://www.cnblogs.com/floyd/AddToFavorite.aspx?id=1559936">收藏</a> <a href="#" onclick="PutInWz();return false;">网摘</a>  </div>
	</div>
	<img src="1559936.html" height="1" width="1">
	
<!--
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
<rdf:Description
rdf:about="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html"
dc:identifier="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html"
dc:title=""
trackback:ping="http://www.cnblogs.com/floyd/services/trackbacks/1559936.aspx" />
</rdf:RDF>
-->

</div><!--end: topics 文章、评论容器-->
<a name="pagedcomment"></a>
<!--done-->
<br>
<div class="feedback_area_title">发表评论</div>
<div class="feedbackNoItems"><span id="span_comment_maxid" style="display: none;">1641884</span></div>
	

		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment("麒麟.NET",1635272,"RdWOhEFsbULGZaf30t4K8I5QiTihPAo4NwIT7vrZsls25i1K7jsvyQ==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1635272,"RdWOhEFsbULGZaf30t4K8I5QiTihPAo4NwIT7vrZsls25i1K7jsvyQ==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=%e9%ba%92%e9%ba%9f.NET" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl00_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl00$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl00_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1635272">#1楼</a><a name="1635272" id="comment_anchor_1635272"></a>2009-09-04 00:23 | <a id="Comments1_CommentList_ctl00_NameLink" href="http://www.cnblogs.com/kirinboy/" target="_top">麒麟.NET</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/%e9%ba%92%e9%ba%9f.NET" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1635272" class="blog_comment_body">不错！<br>不过，既然是泛型类型，那么ExecReader为什么不设计为泛型方法呢？obQuery参数为什么不是T类型呢？</span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment("MicroCoder",1635277,"yZzvWPSoRgupXSCTEHVBJYZiua3bTWXDGPq7LN1g7bWOEov3jgYk1A==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1635277,"yZzvWPSoRgupXSCTEHVBJYZiua3bTWXDGPq7LN1g7bWOEov3jgYk1A==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=MicroCoder" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl01_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl01$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl01_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1635277">#2楼</a><a name="1635277" id="comment_anchor_1635277"></a>2009-09-04 00:49 | <a id="Comments1_CommentList_ctl01_NameLink" href="http://www.cnblogs.com/dushouke/" target="_top">MicroCoder</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/MicroCoder" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1635277" class="blog_comment_body">执行sql语句并且设置SqlParameter可以看看我写的这个：<br><a href="http://www.cnblogs.com/dushouke/archive/2009/08/18/1549358.html" target="_top">http://www.cnblogs.com/dushouke/archive/2009/08/18/1549358.html</a><br>如果执行的是存储过程的话可以使用SqlCommandBuilder的DeriveParameters方法设置SqlParameter，这个在企业库中有实现，你可以看看其中的源码<br>还有那个转换实体的方式，你使用了反射，可以试试使用LINQ Expressions 的方式<br><a href="http://www.cnblogs.com/dushouke/archive/2009/08/21/using-linq-expressions-to-generate-dynamic-methods.html" target="_top">http://www.cnblogs.com/dushouke/archive/2009/08/21/using-linq-expressions-to-generate-dynamic-methods.html</a><br></span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment("Daniel Cai",1635402,"x1CeZIQEYNZfhPFeH/IfR6Moye3sTCakBheEfWfIk/yBRqs7sw8p2g==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1635402,"x1CeZIQEYNZfhPFeH/IfR6Moye3sTCakBheEfWfIk/yBRqs7sw8p2g==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=Daniel+Cai" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl02_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl02$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl02_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1635402">#3楼</a><a name="1635402" id="comment_anchor_1635402"></a>2009-09-04 09:05 | <a id="Comments1_CommentList_ctl02_NameLink" href="http://www.cnblogs.com/ViewState/" target="_top">Daniel Cai</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/Daniel+Cai" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1635402" class="blog_comment_body">少了个缓存的过程，否则这个速度。<br></span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment("singleblue",1635438,"l3SeZRzOEM+VwgJb0wMcQsWUbR44vWjSW47+ZXphDa0ANRzB+9BtGQ==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1635438,"l3SeZRzOEM+VwgJb0wMcQsWUbR44vWjSW47+ZXphDa0ANRzB+9BtGQ==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=singleblue" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl03_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl03$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl03_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1635438">#4楼</a><a name="1635438" id="comment_anchor_1635438"></a>2009-09-04 09:25 | <a id="Comments1_CommentList_ctl03_NameLink" href="http://www.cnblogs.com/singleblue/" target="_top">singleblue</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/singleblue" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1635438" class="blog_comment_body">没有事务处理？</span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment("webaspx",1635452,"SPZQQVAFFo5eCqngw6Hnf8olRdsz6rprzb4jfQsRj10HOzHs7sAOBQ==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1635452,"SPZQQVAFFo5eCqngw6Hnf8olRdsz6rprzb4jfQsRj10HOzHs7sAOBQ==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=webaspx" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl04_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl04$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl04_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1635452">#5楼</a><a name="1635452" id="comment_anchor_1635452"></a>2009-09-04 09:31 | <a id="Comments1_CommentList_ctl04_NameLink" href="http://www.cnblogs.com/lvcao2099/" target="_top">webaspx</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/webaspx" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1635452" class="blog_comment_body">数据库开启和关闭直接用Using不是更好？</span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment("GuoYong.Che",1635468,"nBBHnc2e++BCSsGXvJ1I51rgbYjrfr14a9j3AeCPj0pWhWIaNPdk6Q==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1635468,"nBBHnc2e++BCSsGXvJ1I51rgbYjrfr14a9j3AeCPj0pWhWIaNPdk6Q==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=GuoYong.Che" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl05_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl05$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl05_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1635468">#6楼</a><a name="1635468" id="comment_anchor_1635468"></a>2009-09-04 09:37 | <a id="Comments1_CommentList_ctl05_NameLink" href="http://www.cnblogs.com/gyche/" target="_top">GuoYong.Che</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/GuoYong.Che" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1635468" class="blog_comment_body">性能上测试了没？</span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment("Damon King",1635471,"YQtM+/6T5am+3BL8d37JducPgYpRtY85X/8wfUWr8/MCpiTiU2vC2A==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1635471,"YQtM+/6T5am+3BL8d37JducPgYpRtY85X/8wfUWr8/MCpiTiU2vC2A==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=Damon+King" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl06_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl06$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl06_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1635471">#7楼</a><a name="1635471" id="comment_anchor_1635471"></a>2009-09-04 09:37 | <a id="Comments1_CommentList_ctl06_NameLink" href="http://www.cnblogs.com/damonking/" target="_top">Damon King</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/Damon+King" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1635471" class="blog_comment_body"><a href="http://www.codeproject.com/KB/database/DynamicMethod_ILGenerator.aspx?msg=2123394" target="_top">http://www.codeproject.com/KB/database/DynamicMethod_ILGenerator.aspx?msg=2123394</a><br>推荐博主使用这个来实现ORM，性能更高。</span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment("Damon King",1635483,"YQtM+/6T5am+3BL8d37JducPgYpRtY85X/8wfUWr8/MCpiTiU2vC2A==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1635483,"YQtM+/6T5am+3BL8d37JducPgYpRtY85X/8wfUWr8/MCpiTiU2vC2A==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=Damon+King" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl07_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl07$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl07_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1635483">#8楼</a><a name="1635483" id="comment_anchor_1635483"></a>2009-09-04 09:41 | <a id="Comments1_CommentList_ctl07_NameLink" href="http://www.cnblogs.com/damonking/" target="_top">Damon King</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/Damon+King" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1635483" class="blog_comment_body"><a href="#1635402" title="查看所回复的评论">@</a>Daniel Cai<br>缓存还是不写Helper里的好，独立一个库更灵活。</span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment("coolkiss",1635485,"2WrYCkpwwWqYZJmGTdofCg3NbWpoqKeHN1v+tlLiSsu510vYq0kTeA==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1635485,"2WrYCkpwwWqYZJmGTdofCg3NbWpoqKeHN1v+tlLiSsu510vYq0kTeA==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=coolkiss" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl08_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl08$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl08_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1635485">#9楼</a><a name="1635485" id="comment_anchor_1635485"></a>2009-09-04 09:42 | <a id="Comments1_CommentList_ctl08_NameLink" href="http://www.cnblogs.com/coolkiss/" target="_top">coolkiss</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/coolkiss" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1635485" class="blog_comment_body">先支持一下小泽圆先...<br>然后学习ing....</span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment("Vincent Yang",1635490,"Vo5qVtuhIFDLOaCk8dldPHYVKTgiBRkTz3gf282GOby4mK5TBhxEIg==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1635490,"Vo5qVtuhIFDLOaCk8dldPHYVKTgiBRkTz3gf282GOby4mK5TBhxEIg==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=Vincent+Yang" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl09_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl09$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl09_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1635490">#10楼</a><a name="1635490" id="comment_anchor_1635490"></a>2009-09-04 09:44 | <a id="Comments1_CommentList_ctl09_NameLink" href="http://www.cnblogs.com/javafun/" target="_top">Vincent Yang</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/Vincent+Yang" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1635490" class="blog_comment_body">感觉就是从subsonic里面掏出来的一块</span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment("NormRen",1635505,"dn/sLdKAqmm72iwH7qcZmrnR+spEdl9Ifh32tVuknfAsI77XX6EunQ==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1635505,"dn/sLdKAqmm72iwH7qcZmrnR+spEdl9Ifh32tVuknfAsI77XX6EunQ==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=NormRen" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl10_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl10$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl10_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1635505">#11楼</a><a name="1635505" id="comment_anchor_1635505"></a>2009-09-04 09:51 | <a id="Comments1_CommentList_ctl10_NameLink" href="http://www.cnblogs.com/normren/" target="_top">NormRen</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/NormRen" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1635505" class="blog_comment_body">public PagedList&lt;T&gt; GetPageList(string strTotalSQL, object obTotalQuery, string strSQL, object obQuery, int intPageIndex, int intPageSize)<br><br>这个方法调用的List&lt;T&gt; list = GetList(strSQL, obQuery);<br>是不是只返回当前页的实体好一点？</span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment("邀月",1635520,"N9voHu7/XmVHEMiEBmKUybfkqwCcIfTF25dLsaqov25wUoHoco3Agg==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1635520,"N9voHu7/XmVHEMiEBmKUybfkqwCcIfTF25dLsaqov25wUoHoco3Agg==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=%e9%82%80%e6%9c%88" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl11_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl11$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl11_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1635520">#12楼</a><a name="1635520" id="comment_anchor_1635520"></a>2009-09-04 09:56 | <a id="Comments1_CommentList_ctl11_NameLink" href="http://www.cnblogs.com/downmoon/" target="_top">邀月</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/%e9%82%80%e6%9c%88" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1635520" class="blog_comment_body">感谢楼主分析，根据我的一份简单测试,<br><b>从Reader流转化为List&lt;T&gt;或IList&lt;T&gt;时，Reflect方法效率最低</b><br>看看我的测试　<br><a href="http://www.cnblogs.com/downmoon/archive/2008/09/01/1281118.html" target="_top">http://www.cnblogs.com/downmoon/archive/2008/09/01/1281118.html</a></span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment(".Net热爱者",1635573,"SLV7PV//h8mwJ661QelNKqH/XCnaA2gpj2iob3zx21GCyT9+3t5RJw==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1635573,"SLV7PV//h8mwJ661QelNKqH/XCnaA2gpj2iob3zx21GCyT9+3t5RJw==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=.Net%e7%83%ad%e7%88%b1%e8%80%85" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl12_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl12$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl12_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1635573">#13楼</a><a name="1635573" id="comment_anchor_1635573"></a>[<span class="louzhu">楼主</span>]2009-09-04 10:25 | <a id="Comments1_CommentList_ctl12_NameLink" href="http://www.cnblogs.com/floyd/" target="_top">.Net热爱者</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/.Net%e7%83%ad%e7%88%b1%e8%80%85" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1635573" class="blog_comment_body">因为是第一次写关于ADO.NET的。。加上这次小项目没有需要用到存储过程。。性能方面要求也不要，所以就没测试过。。。这个还在完善当中。。。谢谢大家提的意见。。。</span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment("Selfocus",1635624,"DG/BJiqnnQAM6nPdrJWrO+i3j8E+g/aWX5wXdou0aOe+17P74LVrYA==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1635624,"DG/BJiqnnQAM6nPdrJWrO+i3j8E+g/aWX5wXdou0aOe+17P74LVrYA==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=Selfocus" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl13_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl13$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl13_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1635624">#14楼</a><a name="1635624" id="comment_anchor_1635624"></a>2009-09-04 10:48 | <a id="Comments1_CommentList_ctl13_NameLink" href="http://www.cnblogs.com/Selfocus/" target="_top">Selfocus</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/Selfocus" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1635624" class="blog_comment_body">先顶，再看！</span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment("吉日嘎拉",1635645,"09lKp6nG9nel+aU99r5uIhbq2He+tMmShoBL9DAyoX/x+Gc1GCQaxA==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1635645,"09lKp6nG9nel+aU99r5uIhbq2He+tMmShoBL9DAyoX/x+Gc1GCQaxA==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=%e5%90%89%e6%97%a5%e5%98%8e%e6%8b%89" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl14_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl14$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl14_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1635645">#15楼</a><a name="1635645" id="comment_anchor_1635645"></a>2009-09-04 11:01 | <a id="Comments1_CommentList_ctl14_NameLink" href="http://www.cnblogs.com/jirigala/" target="_top">吉日嘎拉</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/%e5%90%89%e6%97%a5%e5%98%8e%e6%8b%89" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1635645" class="blog_comment_body">代码应该放一起，供下载比较好，<br>还有你的编码质量很高啊，难得看到写代码这么规范的。<br>比 金色海洋的代码比，老好了，大家应该都向你学习。<br><br>反射用的多了？ 会不会影响运行效率？<br></span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment("吉日嘎拉",1635646,"09lKp6nG9nel+aU99r5uIhbq2He+tMmShoBL9DAyoX/x+Gc1GCQaxA==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1635646,"09lKp6nG9nel+aU99r5uIhbq2He+tMmShoBL9DAyoX/x+Gc1GCQaxA==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=%e5%90%89%e6%97%a5%e5%98%8e%e6%8b%89" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl15_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl15$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl15_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1635646">#16楼</a><a name="1635646" id="comment_anchor_1635646"></a>2009-09-04 11:01 | <a id="Comments1_CommentList_ctl15_NameLink" href="http://www.cnblogs.com/jirigala/" target="_top">吉日嘎拉</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/%e5%90%89%e6%97%a5%e5%98%8e%e6%8b%89" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1635646" class="blog_comment_body">推荐 +1 </span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment("Assion Yang",1635674,"zK8O2eqNUsEROGjJSvj2i/P5dNLjr8LGhZlmdhybECUvVJZ/vCP29w==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1635674,"zK8O2eqNUsEROGjJSvj2i/P5dNLjr8LGhZlmdhybECUvVJZ/vCP29w==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=Assion+Yang" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl16_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl16$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl16_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1635674">#17楼</a><a name="1635674" id="comment_anchor_1635674"></a>2009-09-04 11:17 | <a id="Comments1_CommentList_ctl16_NameLink" href="http://www.cnblogs.com/assion/" target="_top">Assion Yang</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/Assion+Yang" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1635674" class="blog_comment_body">楼主看看我以前写的一个<br><br><a href="http://www.cnblogs.com/assion/archive/2009/07/27/1531694.html" target="_top">http://www.cnblogs.com/assion/archive/2009/07/27/1531694.html</a></span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment(".Net热爱者",1635761,"SLV7PV//h8mwJ661QelNKqH/XCnaA2gpj2iob3zx21GCyT9+3t5RJw==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1635761,"SLV7PV//h8mwJ661QelNKqH/XCnaA2gpj2iob3zx21GCyT9+3t5RJw==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=.Net%e7%83%ad%e7%88%b1%e8%80%85" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl17_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl17$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl17_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1635761">#18楼</a><a name="1635761" id="comment_anchor_1635761"></a>[<span class="louzhu">楼主</span>]2009-09-04 12:01 | <a id="Comments1_CommentList_ctl17_NameLink" href="http://www.cnblogs.com/floyd/" target="_top">.Net热爱者</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/.Net%e7%83%ad%e7%88%b1%e8%80%85" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1635761" class="blog_comment_body"><a href="#1635645" title="查看所回复的评论">@</a>吉日嘎拉<br>呵呵。。第一次听见有人说我的编码质量高，偶会努力的。。</span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment(".Net热爱者",1635763,"SLV7PV//h8mwJ661QelNKqH/XCnaA2gpj2iob3zx21GCyT9+3t5RJw==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1635763,"SLV7PV//h8mwJ661QelNKqH/XCnaA2gpj2iob3zx21GCyT9+3t5RJw==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=.Net%e7%83%ad%e7%88%b1%e8%80%85" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl18_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl18$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl18_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1635763">#19楼</a><a name="1635763" id="comment_anchor_1635763"></a>[<span class="louzhu">楼主</span>]2009-09-04 12:02 | <a id="Comments1_CommentList_ctl18_NameLink" href="http://www.cnblogs.com/floyd/" target="_top">.Net热爱者</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/.Net%e7%83%ad%e7%88%b1%e8%80%85" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1635763" class="blog_comment_body"><a href="#1635674" title="查看所回复的评论">@</a>Assion Yang<br>反射哦。。不过偶不太喜欢用字符串拼装。。。学习中。。</span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment("Assion Yang",1635789,"zK8O2eqNUsEROGjJSvj2i/P5dNLjr8LGhZlmdhybECUvVJZ/vCP29w==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1635789,"zK8O2eqNUsEROGjJSvj2i/P5dNLjr8LGhZlmdhybECUvVJZ/vCP29w==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=Assion+Yang" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl19_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl19$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl19_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1635789">#20楼</a><a name="1635789" id="comment_anchor_1635789"></a>2009-09-04 12:24 | <a id="Comments1_CommentList_ctl19_NameLink" href="http://www.cnblogs.com/assion/" target="_top">Assion Yang</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/Assion+Yang" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1635789" class="blog_comment_body"><a href="#1635763" title="查看所回复的评论">@</a>.Net热爱者<br>我那拼的也是@参数形式啊，实际转到DBHelper层还是用的@参数的。<br>比如参数<br><br>List&lt;DbParamer&gt; paramers=new List&lt;DbParamer&gt;();<br>paramers.Add(DbCreateParamer("@Name",Name));</span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment("东风31",1635985,"snWvxuhkUuBNhmYbvei72i/JnZV/eOYu1Xok2m29Q41k5YQPajEM1Q==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1635985,"snWvxuhkUuBNhmYbvei72i/JnZV/eOYu1Xok2m29Q41k5YQPajEM1Q==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=%e4%b8%9c%e9%a3%8e31" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl20_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl20$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl20_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1635985">#21楼</a><a name="1635985" id="comment_anchor_1635985"></a>2009-09-04 14:06 | <a id="Comments1_CommentList_ctl20_NameLink" href="http://www.cnblogs.com/jchen1980/" target="_top">东风31</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/%e4%b8%9c%e9%a3%8e31" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1635985" class="blog_comment_body">泼下凉水<br>1.匈牙利命名法在.net里已经不被推荐了。<br>2.查询出所有数据然后在内存中筛选的分页方式，在产品代码里是不会允许出现的，性能太差了，有几等于无.<br>3.GetList方法没有关闭Reader和Connection</span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment(".Net热爱者",1636082,"SLV7PV//h8mwJ661QelNKqH/XCnaA2gpj2iob3zx21GCyT9+3t5RJw==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1636082,"SLV7PV//h8mwJ661QelNKqH/XCnaA2gpj2iob3zx21GCyT9+3t5RJw==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=.Net%e7%83%ad%e7%88%b1%e8%80%85" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl21_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl21$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl21_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1636082">#22楼</a><a name="1636082" id="comment_anchor_1636082"></a>[<span class="louzhu">楼主</span>]2009-09-04 15:04 | <a id="Comments1_CommentList_ctl21_NameLink" href="http://www.cnblogs.com/floyd/" target="_top">.Net热爱者</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/.Net%e7%83%ad%e7%88%b1%e8%80%85" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1636082" class="blog_comment_body"><a href="#1635985" title="查看所回复的评论">@</a>东风31<br>1.匈牙利命名法在.net里已经不被推荐了。<br>//貌似是哦。。不过个人蛮喜欢。<br><br>2.查询出所有数据然后在内存中筛选的分页方式，在产品代码里是不会允许出现的，性能太差了，有几等于无. <br>//很明显，我是在数据库层分页的。调用例子就说明了。<br><br>3.GetList方法没有关闭Reader和Connection<br>//关闭方法的话，在调用例子那里有。。。</span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment("rad",1636148,"+mm3BDejIqT0CwaHtsb0wj6B/xiuR8jXWhZaWgTuGy+Suxu/Vy4CgA==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1636148,"+mm3BDejIqT0CwaHtsb0wj6B/xiuR8jXWhZaWgTuGy+Suxu/Vy4CgA==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=rad" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl22_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl22$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl22_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1636148">#23楼</a><a name="1636148" id="comment_anchor_1636148"></a>2009-09-04 15:34 | <a id="Comments1_CommentList_ctl22_NameLink" href="http://home.cnblogs.com/69432/" target="_top">rad</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/rad" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1636148" class="blog_comment_body"><fieldset class="comment_quote"><legend><a href="#1635645" title="查看引用原文">引用</a></legend>吉日嘎拉：<br>代码应该放一起，供下载比较好，<br>还有你的编码质量很高啊，难得看到写代码这么规范的。<br>比 金色海洋的代码比，老好了，大家应该都向你学习。<br><br>反射用的多了？ 会不会影响运行效率？<br></fieldset><br>是的 代码质量真的很高<br> public T GetTM(string strSQL, object obQuery)<br></span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment("FlykyeLin",1636943,"")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1636943,"")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl23_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl23$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl23_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1636943">#24楼</a><a name="1636943" id="comment_anchor_1636943"></a>2009-09-05 13:29 | <a id="Comments1_CommentList_ctl23_NameLink" target="_blank">FlykyeLin[未注册用户]</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1636943" class="blog_comment_body">赞一个先！小泽圆在。net路途上越来越牛逼了。离深圳不远了。。<br>GetTM 这个命名好恶心！</span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment(".Net热爱者",1638125,"SLV7PV//h8mwJ661QelNKqH/XCnaA2gpj2iob3zx21GCyT9+3t5RJw==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1638125,"SLV7PV//h8mwJ661QelNKqH/XCnaA2gpj2iob3zx21GCyT9+3t5RJw==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=.Net%e7%83%ad%e7%88%b1%e8%80%85" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl24_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl24$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl24_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1638125">#25楼</a><a name="1638125" id="comment_anchor_1638125"></a>[<span class="louzhu">楼主</span>]2009-09-07 09:46 | <a id="Comments1_CommentList_ctl24_NameLink" href="http://www.cnblogs.com/floyd/" target="_top">.Net热爱者</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/.Net%e7%83%ad%e7%88%b1%e8%80%85" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1638125" class="blog_comment_body"><a href="#1636943" title="查看所回复的评论">@</a>FlykyeLin<br>呃。。。本来是想写GetTableModel的，后来一懒，就变成了缩写了。。。</span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment("chinaagan",1641642,"RWPCjwE0Ous+7+dCOK48qEx/kIAVMrFqSrmd/fBVUZJQa+VVsAl4TQ==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1641642,"RWPCjwE0Ous+7+dCOK48qEx/kIAVMrFqSrmd/fBVUZJQa+VVsAl4TQ==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=chinaagan" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl25_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl25$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl25_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1641642">#26楼</a><a name="1641642" id="comment_anchor_1641642"></a>2009-09-09 21:32 | <a id="Comments1_CommentList_ctl25_NameLink" href="http://www.cnblogs.com/chinaagan/" target="_top">chinaagan</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/chinaagan" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1641642" class="blog_comment_body">非常感谢博主的分享。 <br>我把代码copy执行了一下。 <br>在ResumeTM的代码 object obQuery = new { JobInfoId=intJobInfoId}; <br>是报错的。 <br>我不得不新建了一个查询类JobInfo。 <br> public class JobInfo <br>    { <br>        private int _intJobInfoId; <br><br>        public int AccountID <br>        { <br>            get { return _intJobInfoId; } <br>            set { _intJobInfoId = value; } <br>        } <br>    } <br><br>ps: <br>考虑到ExecReader只能按顺序取值，容易报错的问题。 <br>新增了一个类 <br> public DataTable ExecDataTable(string strSQL, object obQuery) <br>    { <br>        SqlCommand command = new SqlCommand(strSQL, Connection); <br><br>        if (obQuery != null) <br>        { <br>            PropertyInfo[] pis = obQuery.GetType().GetProperties(); <br><br>            foreach (PropertyInfo p in pis) <br>            { <br>                command.Parameters.Add(new SqlParameter(p.Name, p.GetValue(obQuery, null))); <br>            } <br>        } <br>        DataTable dt = new DataTable(); <br>        SqlDataAdapter ada = new SqlDataAdapter(command); <br>        ada.Fill(dt); <br><br>        return dt; <br>    } <br>修改了GetList类的代码，如下： <br> //调用执行查询语句函数，返回SqlDataReader <br>public List&lt;T&gt; GetList(string strSQL, object obQuery) <br>    { <br>        DataTable dt = ExecDataTable(strSQL, obQuery); <br>        //定义返回的列表 <br>        List&lt;T&gt; list = new List&lt;T&gt;(); <br>        //定义T类型的实体 <br>        T model = new T(); <br>        //获取T类型实体的属性类型和值 <br>        PropertyInfo[] pis = model.GetType().GetProperties(); <br>        //获取数据库返回的列数 <br>        int intColCount = dt.Columns.Count; <br>        foreach (DataRow dr in dt.Rows) <br>        { <br>            // 重新实例化T <br>            model = new T(); <br>            for (int i = 0; i &lt; pis.Length; i++) <br>            { <br>                pis[i].SetValue(model, dr[pis[i].Name].ToString(), null); <br>            } <br><br>            list.Add(model); <br>        } <br><br>        return list; <br><br></span><br>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<a onclick='ReplyComment(".Net热爱者",1641884,"SLV7PV//h8mwJ661QelNKqH/XCnaA2gpj2iob3zx21GCyT9+3t5RJw==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1641884,"SLV7PV//h8mwJ661QelNKqH/XCnaA2gpj2iob3zx21GCyT9+3t5RJw==")' href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=.Net%e7%83%ad%e7%88%b1%e8%80%85" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl26_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl26$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl26_EditLink" causesvalidation="False"></a>
				</div>
				<a href="#1641884">#27楼</a><a name="1641884" id="comment_anchor_1641884"></a>[<span class="louzhu">楼主</span>]<a name="Post"></a>2009-09-10 09:57 | <a id="Comments1_CommentList_ctl26_NameLink" href="http://www.cnblogs.com/floyd/" target="_top">.Net热爱者</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/.Net%e7%83%ad%e7%88%b1%e8%80%85" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<span id="comment_body_1641884" class="blog_comment_body"><a href="#1641642" title="查看所回复的评论">@</a>chinaagan<br>感谢阁下的提点。。。我写这个版本嘛。。还是preview来的。。。还存在很多不足。。只是希望能够做一个启发性的东西。。。目前正在完善和改进。。。</span><br>
			</div>
		</div>
	

<div id="ctl05_comment_form" class="commentform">




<div id="ctl05_divLoginPannel">
<div class="login_tips">注册用户登录后才能发表评论，请 <a href="http://passport.cnblogs.com/login.aspx?ReturnUrl=http%3a%2f%2fwww.cnblogs.com%2ffloyd%2farchive%2f2009%2f09%2f04%2f1559936.html%3flogin%3d1%23commentform" class="underline">登录</a> 或 <a href="http://passport.cnblogs.com/register.aspx?ReturnUrl=http%3a%2f%2fwww.cnblogs.com%2ffloyd%2farchive%2f2009%2f09%2f04%2f1559936.html%23Bottom2" class="underline">注册</a> 。</div>
</div>

<div class="itnews c_ad_block" id="itnews">
<a href="http://news.cnblogs.com/" target="_top">IT新闻</a>:<br>

          ·  <a href="http://news.cnblogs.com/n/55117/" target="_top">在地球轨道上如何使用Outlook</a><br>
	
          ·  <a href="http://news.cnblogs.com/n/55115/" target="_top">微软必应推域名缩略服务binged.it</a><br>
	
          ·  <a href="http://news.cnblogs.com/n/55114/" target="_top">谷歌联手亚马逊在英国推出Android音乐商店</a><br>
	
          ·  <a href="http://news.cnblogs.com/n/55112/" target="_top">Facebook成为Apache软件基金会黄金赞助商</a><br>
	
          ·  <a href="http://news.cnblogs.com/n/55111/" target="_top">IBM荣获2009年美国专利申请冠军</a><br>
	
</div>


<div id="ad_under_comment" class="c_ad_block">
<a href="http://a4.yeshj.com/rd/34138/" target="_top">每天10分钟，轻松学英语</a><br><br>
<div id="google_ads_div_cnblogs_blogpost_bottom1">
<iframe src="index_1.html" style="border: 0pt none ;" marginheight="0" marginwidth="0" name="google_ads_iframe_cnblogs_blogpost_bottom1" id="google_ads_iframe_cnblogs_blogpost_bottom1" scrolling="no" frameborder="0" height="60" width="468"></iframe></div>

<br>
<div id="google_ads_div_cnblogs_blogpost_bottom">
<iframe src="index_2.html" style="border: 0pt none ;" marginheight="0" marginwidth="0" name="google_ads_iframe_cnblogs_blogpost_bottom" id="google_ads_iframe_cnblogs_blogpost_bottom" scrolling="no" frameborder="0" height="250" width="300"></iframe></div>

</div>
<div id="site_nav_under" class="c_ad_block">
网站导航：<br>
<a href="http://www.cnblogs.com/" target="_top">博客园首页</a> &nbsp;<a href="http://news.cnblogs.com/" target="_top">IT新闻</a> &nbsp;<a href="http://home.cnblogs.com/" target="_top">个人主页</a> &nbsp;<a href="http://home.cnblogs.com/ing/" target="_top">闪存</a> &nbsp;<a href="http://job.cnblogs.com/" target="_top">程序员招聘</a> &nbsp;<a href="http://space.cnblogs.com/" target="_top">社区</a> &nbsp;<a href="http://space.cnblogs.com/q/" target="_top">博问</a> &nbsp;<a href="http://wz.cnblogs.com/" target="_top">网摘</a>
</div>
<div id="ad_under_comment2" class="c_ad_block">
<a href="http://www.china-pub.com/STATIC07/0912/zh_ndcx_091212.asp" target="_top"><img src="chinapub_20091222.jpg" alt="" style="border: 0px none ;"></a><br>
<a href="http://www.china-pub.com/itbook/" target="_top">China-pub 计算机图书网上专卖店！6.5万品种2-8折！</a><br>
<a href="http://www.china-pub.com/static07/0901/zh_jueba_090121.asp" target="_top">China-Pub 计算机绝版图书按需印刷服务</a><br>
</div>

<div id="relative_search"><br><b>在知识库中查看：</b><br> <a href="http://kb.cnblogs.com/a/1559936/">编写属于自己的SQLHelper类，泛型+反射</a></div>

</div>


				
	</div><!--end: forFlow -->
	</div><!--end: mainContent 主体内容容器-->

	<div id="sideBar">
		<div id="sideBarMain">
			
<!--done-->
<div class="newsItem">
<h3 class="catListTitle">公告</h3>
	<div id="profile_block"><a href="http://home.cnblogs.com/floyd/" target="_top">我的主页</a>&nbsp; <a href="http://home.cnblogs.com/floyd/detail/" target="_top">个人资料</a><br><a href="http://home.cnblogs.com/floyd/ing/" target="_top">我的闪存</a>&nbsp; <a href="http://space.cnblogs.com/msg/send/.Net%e7%83%ad%e7%88%b1%e8%80%85" target="_top">发短消息</a></div>
</div>

			
<div id="calendar">
<table id="Calendar1_entryCal" class="Cal" title="Calendar" border="0" cellpadding="0" cellspacing="0">
	<tbody><tr><td colspan="7"><table class="CalTitle" border="0" cellspacing="0">
		<tbody><tr><td class="CalNextPrev"><a href="javascript:__doPostBack('Calendar1$entryCal','V3500')" style="color: Black;" title="Go to the previous month">&lt;</a></td><td align="center">2009年9月</td><td class="CalNextPrev" align="right"><a href="javascript:__doPostBack('Calendar1$entryCal','V3561')" style="color: Black;" title="Go to the next month">&gt;</a></td></tr>
	</tbody></table></td></tr><tr><th class="CalDayHeader" abbr="日" scope="col" align="center">日</th><th class="CalDayHeader" abbr="一" scope="col" align="center">一</th><th class="CalDayHeader" abbr="二" scope="col" align="center">二</th><th class="CalDayHeader" abbr="三" scope="col" align="center">三</th><th class="CalDayHeader" abbr="四" scope="col" align="center">四</th><th class="CalDayHeader" abbr="五" scope="col" align="center">五</th><th class="CalDayHeader" abbr="六" scope="col" align="center">六</th></tr><tr><td class="CalOtherMonthDay" align="center">30</td><td class="CalOtherMonthDay" align="center">31</td><td align="center">1</td><td align="center">2</td><td align="center">3</td><td align="center"><a href="http://www.cnblogs.com/floyd/archive/2009/9/4.html"><u>4</u></a></td><td class="CalWeekendDay" align="center">5</td></tr><tr><td class="CalWeekendDay" align="center">6</td><td align="center">7</td><td align="center">8</td><td align="center">9</td><td align="center">10</td><td align="center">11</td><td class="CalWeekendDay" align="center">12</td></tr><tr><td class="CalWeekendDay" align="center">13</td><td align="center">14</td><td align="center">15</td><td align="center">16</td><td align="center">17</td><td align="center">18</td><td class="CalWeekendDay" align="center">19</td></tr><tr><td class="CalWeekendDay" align="center">20</td><td align="center">21</td><td align="center">22</td><td align="center">23</td><td align="center">24</td><td align="center">25</td><td class="CalWeekendDay" align="center">26</td></tr><tr><td class="CalWeekendDay" align="center">27</td><td align="center">28</td><td align="center">29</td><td align="center">30</td><td class="CalOtherMonthDay" align="center">1</td><td class="CalOtherMonthDay" align="center">2</td><td class="CalOtherMonthDay" align="center">3</td></tr><tr><td class="CalOtherMonthDay" align="center">4</td><td class="CalOtherMonthDay" align="center">5</td><td class="CalOtherMonthDay" align="center">6</td><td class="CalOtherMonthDay" align="center">7</td><td class="CalOtherMonthDay" align="center">8</td><td class="CalOtherMonthDay" align="center">9</td><td class="CalOtherMonthDay" align="center">10</td></tr>
</tbody></table>
</div>

			
			<div id="leftcontentcontainer">
				

<div class="mySearch">
<h3 class="catListTitle">搜索</h3>
<div class="div_my_zzk"><input value="" id="q" onkeydown="return zzk_go_enter(event);" class="input_my_zzk" type="text">&nbsp;<input onclick="zzk_go()" value="找找看" id="btnZzk" class="btn_my_zzk" type="button"></div>
</div>
<div class="catListLink">
<h3 class="catListTitle">常用链接</h3>
<ul>

		<li><a id="SingleColumn1_ctl02_rptMainLinks_ctl00_lnkLinkItem" href="http://www.cnblogs.com/floyd/MyPosts.html">我的随笔</a></li>
	
		<li><a id="SingleColumn1_ctl02_rptMainLinks_ctl01_lnkLinkItem" href="http://home.cnblogs.com/floyd/">我的空间</a></li>
	
		<li><a id="SingleColumn1_ctl02_rptMainLinks_ctl02_lnkLinkItem" href="http://space.cnblogs.com/msg/recent">我的短信</a></li>
	
		<li><a id="SingleColumn1_ctl02_rptMainLinks_ctl03_lnkLinkItem" href="http://www.cnblogs.com/floyd/MyComments.html">我的评论</a></li>
	
<li><a id="itemListLink" onclick="this.blur();WarpClass('itemListLink', 'itemListLin_con');return false;" href="#">更多链接</a></li>
</ul>
<div id="itemListLin_con" style="display: none;">
<ul>

		<li><a id="SingleColumn1_ctl02_repeaterLinks_ctl00_lnkLinkItem" title="我发表过评论的随笔" href="http://www.cnblogs.com/floyd/OtherPosts.html">我的参与</a></li>
	
		<li><a id="SingleColumn1_ctl02_repeaterLinks_ctl01_lnkLinkItem" href="http://www.cnblogs.com/floyd/MyNews.html">我的新闻</a></li>
	
		<li><a id="SingleColumn1_ctl02_repeaterLinks_ctl02_lnkLinkItem" href="http://www.cnblogs.com/floyd/RecentComments.html">最新评论</a></li>
	
		<li><a id="SingleColumn1_ctl02_repeaterLinks_ctl03_lnkLinkItem" href="http://www.cnblogs.com/floyd/tag/">我的标签</a></li>
	
</ul>
</div>
</div>
<div class="catListPostArchive">
<h3 class="catListTitle">随笔档案</h3>

<ul>

<li><a id="SingleColumn1_Categories_CatList_ctl00_LinkList_ctl01_Link" href="http://www.cnblogs.com/floyd/archive/2009/09.html">2009年9月 (1)</a> </li>

<li><a id="SingleColumn1_Categories_CatList_ctl00_LinkList_ctl02_Link" href="http://www.cnblogs.com/floyd/archive/2009/06.html">2009年6月 (1)</a> </li>

<li><a id="SingleColumn1_Categories_CatList_ctl00_LinkList_ctl03_Link" href="http://www.cnblogs.com/floyd/archive/2009/05.html">2009年5月 (1)</a> </li>

<li><a id="SingleColumn1_Categories_CatList_ctl00_LinkList_ctl04_Link" href="http://www.cnblogs.com/floyd/archive/2009/03.html">2009年3月 (3)</a> </li>

</ul>

</div>



<div class="catListComment">
<h3 class="catListTitle">最新评论<a id="SingleColumn1__13c141_RSSHyperlink1" title="RSS订阅最最新评论" href="http://www.cnblogs.com/floyd/CommentsRSS.aspx"><img title="RSS订阅最最新评论" src="xml.gif" style="border-width: 0px;"></a></h3>

	
			<div class="divRecentCommentAticle">
				<a id="SingleColumn1__13c141_CommentList_ctl00_Hyperlink2" class="listitem" href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#1641884">1.&nbsp;Re:编写属于自己的SQLHelper类，泛型+反射</a>
			</div>
			<div class="divRecentComment">
				@chinaagan
感谢阁下的提点。。。我写这个版本嘛。。还是preview来的。。。还存在很多不足。。只是希望能够做一个启发性的东西。。。目前正在完善和改进。。。 (.Net热爱者)
			</div>		
		
			<div class="divRecentCommentAticle">
				<a id="SingleColumn1__13c141_CommentList_ctl01_Hyperlink2" class="listitem" href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#1641642">2.&nbsp;Re:编写属于自己的SQLHelper类，泛型+反射</a>
			</div>
			<div class="divRecentComment">
				非常感谢博主的分享。 
我把代码copy执行了一下。 
在ResumeTM的代码 object obQuery = new { JobInfoId=intJobInfoId}; 
是报错的。 
我不得... (chinaagan)
			</div>		
		
			<div class="divRecentCommentAticle">
				<a id="SingleColumn1__13c141_CommentList_ctl02_Hyperlink2" class="listitem" href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#1638125">3.&nbsp;Re:编写属于自己的SQLHelper类，泛型+反射</a>
			</div>
			<div class="divRecentComment">
				@FlykyeLin
呃。。。本来是想写GetTableModel的，后来一懒，就变成了缩写了。。。 (.Net热爱者)
			</div>		
		
			<div class="divRecentCommentAticle">
				<a id="SingleColumn1__13c141_CommentList_ctl03_Hyperlink2" class="listitem" href="http://www.cnblogs.com/floyd/archive/2009/05/08/1452348.html#1636947">4.&nbsp;Re:利用JQuery编写自定义简单的Html控件</a>
			</div>
			<div class="divRecentComment">
				既然发现错误了，为啥还不更正呢？ (flykye)
			</div>		
		
			<div class="divRecentCommentAticle">
				<a id="SingleColumn1__13c141_CommentList_ctl04_Hyperlink2" class="listitem" href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html#1636943">5.&nbsp;Re:编写属于自己的SQLHelper类，泛型+反射</a>
			</div>
			<div class="divRecentComment">
				赞一个先！小泽圆在。net路途上越来越牛逼了。离深圳不远了。。
GetTM 这个命名好恶心！ (FlykyeLin)
			</div>		
		
</div>

<div class="catListView">
<h3 class="catListTitle">阅读排行榜</h3>
	
			<ul>
		
			<li>
				<a id="SingleColumn1_ctl06_TopList_ctl01_Hyperlink1" href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html">1.&nbsp;编写属于自己的SQLHelper类，泛型+反射(3265)</a>
			</li>
		
			<li>
				<a id="SingleColumn1_ctl06_TopList_ctl02_Hyperlink1" href="http://www.cnblogs.com/floyd/archive/2009/03/15/1412194.html">2.&nbsp;泛型 + 扩展方法，打造简单的属于自己的分页类(C#)(338)</a>
			</li>
		
			<li>
				<a id="SingleColumn1_ctl06_TopList_ctl03_Hyperlink1" href="http://www.cnblogs.com/floyd/archive/2009/03/30/1424861.html">3.&nbsp;List<t>中的对象元素进行简单排序(331)</t></a>
			</li>
		
			<li>
				<a id="SingleColumn1_ctl06_TopList_ctl04_Hyperlink1" href="http://www.cnblogs.com/floyd/archive/2009/06/17/1505117.html">4.&nbsp;Unity+单例模式的依赖注入(235)</a>
			</li>
		
			<li>
				<a id="SingleColumn1_ctl06_TopList_ctl05_Hyperlink1" href="http://www.cnblogs.com/floyd/archive/2009/03/13/1410274.html">5.&nbsp;巧用泛型，让所有的数据表操作类都具有增，删，改(LinQ)(206)</a>
			</li>
		
			</ul>
		
</div>

<div class="catListFeedback">
<h3 class="catListTitle">评论排行榜</h3>
	
			<ul>
		
			<li>
				<a id="SingleColumn1_ctl07_TopList_ctl01_Hyperlink1" href="http://www.cnblogs.com/floyd/archive/2009/09/04/1559936.html">1.&nbsp;编写属于自己的SQLHelper类，泛型+反射(27)</a>
			</li>
		
			<li>
				<a id="SingleColumn1_ctl07_TopList_ctl02_Hyperlink1" href="http://www.cnblogs.com/floyd/archive/2009/05/08/1452348.html">2.&nbsp;利用JQuery编写自定义简单的Html控件(3)</a>
			</li>
		
			<li>
				<a id="SingleColumn1_ctl07_TopList_ctl03_Hyperlink1" href="http://www.cnblogs.com/floyd/archive/2009/03/15/1412194.html">3.&nbsp;泛型 + 扩展方法，打造简单的属于自己的分页类(C#)(3)</a>
			</li>
		
			<li>
				<a id="SingleColumn1_ctl07_TopList_ctl04_Hyperlink1" href="http://www.cnblogs.com/floyd/archive/2009/03/30/1424861.html">4.&nbsp;List<t>中的对象元素进行简单排序(2)</t></a>
			</li>
		
			<li>
				<a id="SingleColumn1_ctl07_TopList_ctl05_Hyperlink1" href="http://www.cnblogs.com/floyd/archive/2009/06/17/1505117.html">5.&nbsp;Unity+单例模式的依赖注入(0)</a>
			</li>
		
			</ul>
		
</div>

			</div>
			
		</div><!--end: sideBarMain -->
	</div><!--end: sideBar 侧边栏容器 -->
	<div class="clear"></div>
	</div><!--end: main -->
	<div class="clear"></div>
	<div id="footer">
		
<!--done-->
Copyright ©2010 .Net热爱者
	</div><!--end: footer -->
</div><!--end: home 自定义的最大容器 -->
    </form>
	
	
      
    
    
    
</body>
</html>
